<template>
  <view class="admin" v-if="pageData">
    <pageHeader
      ref="header"
      :isToggle="isToggle"
      :pageData.sync="pageData"
      :info.sync="info"
    ></pageHeader>
    <pageContent
      :info="info"
      :pageData="pageData"
      :isToggle.sync="isToggle"
    >
      <div
        class="flex-col flex-x-center flex-y-center imageArr"
        v-if="!isToggle"
        @click="isToggle = true"
      >
        <image
          src="../static/images/arrow-bottom-icon.png"
          mode="widthFix"
        ></image>
      </div>
    </pageContent>
  </view>
</template>

<script>
import pageHeader from "./components/page-header.vue";
import pageContent from "./components/page-content.vue";
import serviceHome from '@/api/service-home'

export default {
  components: {
    pageHeader,
    pageContent,
  },

  data() {
    return {
      isToggle: false,
      info: {
        top: 0,
        height: "auto",
      },
      pageData: null
    };
  },

  onLoad() {
    this.$utils.hideShareMenu();
  },

  onShow() {
    this.getData();
  },

  methods: {
    changeIsToggle(isToggle) {
      this.isToggle = isToggle;
    },


   async getData() {
    var res = await serviceHome.index({},true)
    // 如果没有用户信息，或者状态不是申请成功，跳转申请页面
    if(!res.data || (res.data.workerInfo && res.data.workerInfo.status != 1)) {
     return this.$utils.toUrl('/service-home/apply/index','redirectTo')
    } 
    this.pageData = res.data

   
    },
  },

  onPullDownRefresh() {
    this.getData();
  },
};
</script>

<style lang="less" scoped>
.admin {
  background: #f8f8f8;
  min-height: 100vh;
  overflow: hidden;
}

.imageArr {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translate(-50%, -24rpx);

  > image {
    width: 56rpx;
    max-height: 20rpx;
  }
}

.ewm {
  width: 500rpx;
}
</style>
